<template>
  <view class="msg-detail-page">
    <view class="msg-detail-header">
      <u-icon name="arrow-left" size="44" @click="goBack" />
      <view class="msg-detail-title">订单消息</view>
    </view>
    <view class="msg-detail-content">
      <view class="msg-detail-time">{{ detail.time }}</view>
      <view class="msg-detail-card">
        <view class="msg-detail-main-title">{{ detail.title }}</view>
        <view class="msg-detail-desc">{{ detail.desc }}</view>
        <view class="msg-detail-order">订单：{{ detail.orderNo }}</view>
        <view class="msg-detail-link" @click="goOrderDetail"
          >查看详情 <u-icon name="arrow-right" size="24"
        /></view>
      </view>
    </view>
  </view>
</template>

<script>
// 本地死数据
const messageList = [
  {
    id: 1,
    time: "2098-11-25 11:42:05",
    title: "订单支付提醒",
    desc: "故宫博物馆成人票，尚未完成支付，即将取消。",
    orderNo: "291125173310086",
  },
  {
    id: 2,
    time: "2098-11-25 11:42:05",
    title: "订单预订成功",
    desc: "故宫博物馆成人票1份，2098-11-26 待使用。",
    orderNo: "291125173310080",
  },
  {
    id: 3,
    time: "2098-11-20 12:04:29",
    title: "订单已使用",
    desc: "故宫博物馆成人票2份，2098-11-20 已使用。欢迎再次预订。",
    orderNo: "291125173510086",
  },
  {
    id: 4,
    time: "2098-11-19 18:20:49",
    title: "订单退款成功",
    desc: "故宫博物馆成人票，退款金额：￥50.00（含保险金额：￥10.00），将于1-7个工作日退还至付款账户。",
    orderNo: "291119173010050",
  },
];

export default {
  data() {
    return {
      detail: {
        time: "",
        title: "",
        desc: "",
        orderNo: "",
      },
    };
  },
  onLoad(options) {
    const id = Number(options.id);
    const msg = messageList.find((item) => item.id === id);
    if (msg) {
      this.detail = msg;
    } else {
      this.detail = {
        time: "",
        title: "消息不存在",
        desc: "",
        orderNo: "",
      };
    }
  },
  methods: {
    goBack() {
      uni.navigateBack();
    },
    goOrderDetail() {
      uni.showToast({ title: "跳转订单详情", icon: "none" });
    },
  },
};
</script>

<style scoped>
.msg-detail-page {
  min-height: 100vh;
  background: #f8f9fb;
}
.msg-detail-header {
  display: flex;
  align-items: center;
  padding: 32rpx 0 0 24rpx;
  background: #fff;
}
.msg-detail-title {
  flex: 1;
  text-align: center;
  font-size: 36rpx;
  font-weight: bold;
  color: #222;
  margin-right: 68rpx;
}
.msg-detail-content {
  padding: 32rpx 24rpx 0 24rpx;
}
.msg-detail-time {
  color: #bbb;
  font-size: 24rpx;
  margin-bottom: 16rpx;
}
.msg-detail-card {
  background: #fff;
  border-radius: 16rpx;
  padding: 32rpx 24rpx;
  box-shadow: 0 2rpx 8rpx #eee;
}
.msg-detail-main-title {
  font-size: 32rpx;
  font-weight: 500;
  margin-bottom: 12rpx;
}
.msg-detail-desc {
  font-size: 28rpx;
  color: #333;
  margin-bottom: 16rpx;
}
.msg-detail-order {
  font-size: 26rpx;
  color: #888;
  margin-bottom: 16rpx;
}
.msg-detail-link {
  color: #2979ff;
  font-size: 26rpx;
  display: flex;
  align-items: center;
  cursor: pointer;
}
</style> 